package monopoly;
import java.io.IOException;

public class player_turn {
	public static void turn() throws IOException {
		if (vars.player_jail == 0) {
			vars.dice = dice.dice_roll(vars.dice);
			vars.dice2 = dice.dice_roll(vars.dice);
			if (vars.dice == vars.dice2) {
				vars.player_doubles++;
				if (vars.player_doubles == 3) {
					System.out
							.println("You have rolled doubles three times and go to jail.");
					vars.player_position = 10;
					vars.player_jail = 1;
				} else {
					vars.var = vars.dice + vars.dice2;
					System.out.println("You roll a " + vars.var);

					System.out.println("You roll doubles.");
					vars.player_doubles++;
					vars.player_position = vars.player_position
							+ vars.var;
				}
			} else {
				vars.player_doubles = 0;
				vars.var = vars.dice + vars.dice2;
				System.out.println("You roll the dice. You roll a "
						+ vars.var);
				vars.player_position = vars.player_position + vars.var;
			}
		} else {
			player.jail();
		}
		vars.finished = 0;
		vars.var = 0;
		if (vars.player_position > 39) {
			System.out.println("You pass go and collect $200");
			vars.player_money = vars.player_money + 200;
			vars.player_position = vars.player_position - 40;
		}
		if (arrays.property_type[vars.player_position] == 0) {
			player.buy_property();
		} else {
			if (arrays.property_type[vars.player_position] == 1) {
				System.out.println("You already own "
						+ arrays.property_name[vars.player_position]);
			}
		}
		if (arrays.property_type[vars.player_position] == 2) {
			player.pay_rent();
		}
		if (arrays.property_type[vars.player_position] == 3) {
			System.out.println("You land on Chance");
			chance.player();
		}
		if (arrays.property_type[vars.player_position] == 4) {
			System.out.println("You land on community chest");
			System.out.println("You collect $20");
			vars.player_money = vars.player_money + 20;
		}
		if (arrays.property_type[vars.player_position] == 5) {
			System.out.println("You land on Go and collect $400");
			vars.player_money = vars.player_money + 400;
		}
		if (arrays.property_type[vars.player_position] == 6) {
			System.out.println("You land on Income Tax and pay $200");
			vars.player_money = vars.player_money - 200;
		}
		if (arrays.property_type[vars.player_position] == 7) {
			System.out.println("You land on luxury tax and pay $100");
			vars.player_money = vars.player_money - 100;
		}
		if (arrays.property_type[vars.player_position] == 8) {
			System.out.println("You visit jail");
		}
		if (arrays.property_type[vars.player_position] == 9) {
			System.out.println("You land on Free Parking.");
		}
		if (arrays.property_type[vars.player_position] == 10) {
			System.out
					.println("You land on Go to Jail. You are now in jail.");
			vars.player_position = 10;
			vars.player_jail = 1;
		}
		if (vars.player_doubles == 0) {
			System.out.println("Your turn ends");
			vars.turn = 1;
		} else {
			System.out
					.println("You take another turn because you rolled doubles");
		}
		if (vars.player_money < 0) {
			vars.finished = 1;
		}
		System.out.println("You now have $" + vars.player_money);
		System.in.read();
	}
}